package com.zpz.framework.zpzoauth.web;

import com.zpz.framework.zpzoauth.common.result.ZpzOauthResultMsg;
import com.zpz.framework.zpzoauth.common.result.ZpzOauthResultStatus;
import com.zpz.framework.zpzoauth.pojo.qo.AddFrameMenuQo;
import com.zpz.framework.zpzoauth.pojo.qo.DeleteFrameMenuQo;
import com.zpz.framework.zpzoauth.pojo.qo.MenuInfoQo;
import com.zpz.framework.zpzoauth.pojo.qo.ModifyFrameMenuQo;
import com.zpz.framework.zpzoauth.pojo.vo.GetMenuVo;
import com.zpz.framework.zpzoauth.pojo.vo.GetRoleMenuByUserCodeVo;
import com.zpz.framework.zpzoauth.service.ZpzOauthFrameMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author zhangpanzhi
 * @description 菜单管理
 * @create 2019-07-04 16:11
 */
@Api(tags = "菜单管理")
@RestController
@RequestMapping(value = "/zpzOauthMenu")
public class ZpzOauthMenuController{
    @Resource
    private ZpzOauthFrameMenuService zpzOauthFrameMenuService;

    @ApiOperation(value = "获取菜单树结构信息[当前客户端下的所有菜单]（100011） |适用于（） |负责人：zhangpanzhi",
            notes = "  \n 数据安全：无," +
                    "  \n返回码：0（OK），")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "menuInfoQo", value = "参数", paramType = "body", dataType = "MenuInfoQo", required = true
            )})
    @PostMapping(value = "/getMenuList")
    public ZpzOauthResultMsg<List<GetMenuVo>> getMenuList(HttpServletRequest request, @RequestBody MenuInfoQo menuInfoQo) throws Exception{
        if (StringUtils.isBlank(menuInfoQo.getClientId())){
            return ZpzOauthResultMsg.customResultStatus(ZpzOauthResultStatus.CLIENTID_NULL_31054);
        }
        return zpzOauthFrameMenuService.getMenuList(request,menuInfoQo.getClientId());
    }

    @ApiOperation(value = "获取当前登录用户菜单树结构信息（100006） |负责人：zhangpanzhi",
            notes = "  \n 数据安全：无," +
                    "  \n返回码：0（OK），")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "menuInfoQo", value = "参数", paramType = "body", dataType = "MenuInfoQo", required = true
            )})
    @PostMapping(value = "/getCurUserRoleMenu")
    public ZpzOauthResultMsg<List<GetRoleMenuByUserCodeVo>> getCurUserRoleMenu(HttpServletRequest request, @RequestBody MenuInfoQo menuInfoQo) throws Exception{
        return zpzOauthFrameMenuService.getCurUserRoleMenu(request,menuInfoQo);
    }

    @ApiOperation(value = "新增菜单信息（100051） |负责人：zhangpanzhi",
            notes = "  \n 数据安全：无," +
                    "  \n返回码：0（OK），")
    @ApiImplicitParams({@ApiImplicitParam(name = "addFrameMenuQo", value = "参数", paramType = "body", dataType = "AddFrameMenuQo", required = true)})
    @PostMapping(value = "/addframemenuinfo")
    public ZpzOauthResultMsg<Boolean> addframemenuinfo(HttpServletRequest request, @RequestBody AddFrameMenuQo addFrameMenuQo) throws Exception{
        return zpzOauthFrameMenuService.addframemenuinfo(request,addFrameMenuQo);
    }

    @ApiOperation(value = "修改菜单信息（100052） |负责人：zhangpanzhi",
            notes = "  \n 数据安全：无," +
                    "  \n返回码：0（OK），")
    @ApiImplicitParams({@ApiImplicitParam(name = "modifyFrameMenuQo", value = "参数", paramType = "body", dataType = "ModifyFrameMenuQo", required = true)})
    @PostMapping(value = "/updateframemenuinfo")
    public ZpzOauthResultMsg<Boolean> updateframemenuinfo(HttpServletRequest request, @RequestBody ModifyFrameMenuQo modifyFrameMenuQo) throws Exception{
        return zpzOauthFrameMenuService.updateframemenuinfo(request,modifyFrameMenuQo);
    }

    @ApiOperation(value = "删除菜单信息（100053） |负责人：zhangpanzhi",
            notes = "  \n 数据安全：无," +
                    "  \n返回码：0（OK），")
    @ApiImplicitParams({@ApiImplicitParam(name = "deleteFrameMenuQo", value = "参数", paramType = "body", dataType = "DeleteFrameMenuQo", required = true)})
    @PostMapping(value = "/delframemenuinfo")
    public ZpzOauthResultMsg<Boolean> delframemenuinfo(HttpServletRequest request, @RequestBody DeleteFrameMenuQo deleteFrameMenuQo) throws Exception{
        return zpzOauthFrameMenuService.delframemenuinfo(request,deleteFrameMenuQo);
    }

}
